// 统一封装的通知组件，方便后期替换
import { i18nTranslate } from '../i18n';

/**
 * 通知成功
 * @param message = Successful
 * @param duration
 */
export const NotifySuccess = (message?: string) => {
  return new Promise<void>((resolve) => {
    Snackbar.success({
      content: message ?? i18nTranslate('successful'),
      onClosed: resolve,
      position: 'center',
    });
    // showNotify({
    //   type: 'success',
    //   message,
    //   duration,
    //   onClose() {
    //     resolve();
    //   },
    // });
  });
};

/**
 * 通知错误
 * @param message
 * @param duration
 */
export const NotifyError = (message: string) => {
  return new Promise<void>((resolve) => {
    Snackbar.error({
      content: message,
      onClosed: resolve,
      position: 'center',
    });
    // showNotify({
    //   type: 'danger',
    //   message,
    //   duration,
    //   onClose() {
    //     resolve();
    //   },
    // });
  });
};

/**
 * 通知警告
 * @param message
 * @param duration
 */
export const NotifyWarn = (message: string) => {
  return new Promise<void>((resolve) => {
    Snackbar.warning({
      content: message,
      onClosed: resolve,
      position: 'center',
    });
    // showNotify({
    //   type: 'warning',
    //   message,
    //   duration,
    //   onClose() {
    //     resolve();
    //   },
    // });
  });
};

/**
 * 关闭全部通知
 * @returns
 */
export const NotifyCloseAll = () => {
  Snackbar.clear();
  //   closeNotify();
};
